#ifndef __TASKQUEUE_H__
#define __TASKQUEUE_H__

#include <thread>
#include <mutex>
#include <condition_variable>
#include <queue>
#include <functional>

using namespace std;

// 任务
using ElementType=function<void()>;

class TaskQueue
{
public:
    TaskQueue(size_t queSize);

    void push(ElementType&& task);

    ElementType pop();

    bool full();

    bool empty();

    ~TaskQueue();
private:
    size_t _queSize;
    queue<ElementType> _que;
    mutex _mutex;
    condition_variable _condFull;
    condition_variable _condEmpty;
};

#endif 